<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core">
    <h:head>
    </h:head>
    <h:body>

        <ui:composition template="./template/template.xhtml">

            <ui:define name="content">

                <!--logged-->
                <h:panelGroup rendered="#{userManager.loggedIn}" >

                    <h:panelGrid columns="2">
                        <h:panelGroup>
                            <h:form id="Form1" >
                            <h:panelGrid columns="2">
                                <h:panelGroup style="vertical-align: top"   >

                                    <h3   >Users Connected</h3>
                                    <div style="overflow:auto; width: 100px; vertical-align: top; height:380px;" id="users" >

                                        <h:dataTable value="#{chatUserBean.userList}" var="currentu" style="" >
                                            <h:column>
                                                <h:outputText value="#{currentu}" style=" font-weight: bold; color: #FF8C00 " />
                                            </h:column>
                                        </h:dataTable>
                                    </div>
                                </h:panelGroup >

                                <h:panelGroup style="vertical-align: top" >
                                    
                                        <div style="height: 380px; overflow:auto; width: 400px;" id="chat" >
                                            <h:dataTable value="#{messageBean.textList}" var="current" style="vertical-align: bottom" >
                                                <h:column>
                                                    <script type="javascript">
                                                        var objDiv = document.getElementById("chat");
                                                        objDiv.scrollTop = objDiv.scrollHeight;
                                                    </script>
                                                    <h:outputText value="#{current.text}"/>
                                                </h:column>
                                            </h:dataTable>
                                        </div>

                                   
                                </h:panelGroup>

                            </h:panelGrid>
                            <h:inputText value="#{chatBean.message}" style="width: 475px" />
                            <h:commandButton id="buttonSave"  value="Send"
                                             action="#{chatBean.sendMessage}"/>
                             </h:form>

                        </h:panelGroup>
                    <h:panelGroup>

                        <h:panelGroup >
                            <div style="padding:15px;">
                                <h:form>
                                    <h:commandLink action="home">
                                        <h:graphicImage value="./resources/images/start_button.png" />
                                    </h:commandLink>
                                </h:form>
                            </div>
                        </h:panelGroup>

                        <h:panelGroup >
                            <div style="padding:15px;">
                                <h3>Started Games</h3>
                                <div style="height: 180px; overflow:auto; width: 200px;" id="games" >

                                    LOLZ
                                </div>
                            </div>
                        </h:panelGroup>
                    </h:panelGroup>
                    </h:panelGrid>

                </h:panelGroup>

                <!--not logged-->
                <h:form id="log">
                    <h:panelGroup rendered="#{!userManager.loggedIn}">
                        <center>You are not Logged in. Please login. <br/>
                            <h:commandLink value="Login" action="login" /></center>
                    </h:panelGroup>
                </h:form>


            </ui:define>

        </ui:composition>

    </h:body>
</html>

